toolchain("arm32-linux-gcc")
    set_kind("standalone")
    set_cross("arm-linux-gnueabihf-")
    -- 如 bin 不在 sdkdir/bin，再追加 set_bindir()
toolchain_end()

target('supervisor')
    set_kind('binary')
    set_targetdir('bin')
    set_objectdir('.xmake/build/.obj')
    set_dependir('.xmake/build/.dep')
    set_warnings('all')
    set_languages('cxx11')
    set_toolchains('arm32-linux-gcc')
    add_ldflags("-static-libgcc", "-static-libstdc++")
    add_ldflags("-static", {force = true})

    if is_os('windows') then
        add_links('user32', 'advapi32')
        add_files('supervisor.rc')
    else
        before_build(function(t, p)
            -- cprint("${green}[%3d%%]:${clear} make res for linux", p.progress.start, t:name())
            os.execv('zip', {'-r', 'res.zip', 'res'})
            os.execv('arm-linux-gnueabihf-objcopy', {'-I', 'binary', '-B', 'arm', '-O', 'elf32-littlearm', 'res.zip', 'res.o'})
        end)

        after_build(function(t, p)
            os.execv('rm', {'-f', 'res.o'})
        end)

        add_links('pthread')
        add_files('res.o')
    end

    add_files('*.cc', '*.c')
target_end()